<?php

declare(strict_types=1);

namespace App\Util;

use Illuminate\Http\JsonResponse;
use Illuminate\Support\MessageBag;

class InfoUtil
{
    static function adminErr($msg = '')
    {
        $error = new MessageBag([
            'title'   => '错误信息',
            'message' => $msg,
        ]);
        return back()->with(compact('error'));
    }

    static function adminSuc($msg = '')
    {
        $success = new MessageBag([
            'title'   => '提示',
            'message' => $msg,
        ]);
        return back()->with(compact('success'));
    }

    /**
     * 行内编辑
     * @param string $msg
     * @return JsonResponse
     */
    static function lineEditErr(string $msg = ''){
        return response()->json([
            'status' => false,
            'message' => $msg,
        ]);
    }
}
